import BaseApi from "@/api/BaseApi.ts";
import type IBaseResp from "@/type/IBaseResp.ts";
import type ISysPermissionReq from "../type/req/ISysPermissionReq.ts";
import type ISysPermissionResp from "../type/resp/ISysPermissionResp.ts";

class SysPermissionApi extends BaseApi {

    constructor() {
        super("/rbac/sysPermission")
    }

    /**
     * 分页查询
     */
    tree = (name?: String) => {
        return this.get<ISysPermissionResp[], String>('tree', name)
    }

    /**
     * 根据id查询数据
     */
    queryById = (id: String) => {
        return this.get('queryById', {id})
    }

    /**
     * 根据id查询数据
     */
    queryByPid = (pid: String) => {
        return this.get<ISysPermissionResp[], {pid: String}>('queryByPid', {pid})
    }

    /**
     * 根据有无id新增或编辑数据
     */
    addOrUpdate = (sysPermissionReq: ISysPermissionReq) => {
        return this.post<string, ISysPermissionReq>('addOrUpdate', sysPermissionReq)
    }

    /**
     * 根据id删除数据
     */
    deleteById = (ids: string[]) => {
        return this.delete<string>('delete', ids)
    }

}

export default new SysPermissionApi()